<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The DirectoryIterator class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="callbackfilteriterator.construct.html">« CallbackFilterIterator::__construct</a></li>
      <li style="float: right;"><a href="directoryiterator.construct.html">DirectoryIterator::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="spl.iterators.html">迭代器</a></li>
    <li>The DirectoryIterator class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.directoryiterator" class="reference">
 <h1 class="title">The DirectoryIterator class</h1>
 
 
 <div class="partintro"><p class="verinfo">(PHP 5, PHP 7, PHP 8)</p>
 

  <div class="section" id="directoryiterator.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    The DirectoryIterator class provides a simple interface for viewing
    the contents of filesystem directories.
   </p>
  </div>

 
  <div class="section" id="directoryiterator.synopsis">
   <h2 class="title">类摘要</h2>
 

   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">DirectoryIterator</strong>
     </span>

     <span class="ooclass">
      <span class="modifier">extends</span>
       <a href="class.splfileinfo.html" class="classname">SplFileInfo</a>
     </span>

     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.seekableiterator.html" class="interfacename">SeekableIterator</a></span> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.construct.html" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$directory</code></span>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.current.html" class="methodname">current</a></span>(): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getatime.html" class="methodname">getATime</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getbasename.html" class="methodname">getBasename</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$suffix</code><span class="initializer"> = &quot;&quot;</span></span>): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getctime.html" class="methodname">getCTime</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getextension.html" class="methodname">getExtension</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getfilename.html" class="methodname">getFilename</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getgroup.html" class="methodname">getGroup</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getinode.html" class="methodname">getInode</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getmtime.html" class="methodname">getMTime</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getowner.html" class="methodname">getOwner</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getpath.html" class="methodname">getPath</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getpathname.html" class="methodname">getPathname</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getperms.html" class="methodname">getPerms</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.getsize.html" class="methodname">getSize</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.gettype.html" class="methodname">getType</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.isdir.html" class="methodname">isDir</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.isdot.html" class="methodname">isDot</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.isexecutable.html" class="methodname">isExecutable</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.isfile.html" class="methodname">isFile</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.islink.html" class="methodname">isLink</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.isreadable.html" class="methodname">isReadable</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.iswritable.html" class="methodname">isWritable</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.key.html" class="methodname">key</a></span>(): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.next.html" class="methodname">next</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.rewind.html" class="methodname">rewind</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.seek.html" class="methodname">seek</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$offset</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="directoryiterator.tostring.html" class="methodname">__toString</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="directoryiterator.valid.html" class="methodname">valid</a></span>(): <span class="type">bool</span></div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的方法 */</div>
    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getatime.html" class="methodname">SplFileInfo::getATime</a></span>(): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getbasename.html" class="methodname">SplFileInfo::getBasename</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$suffix</code><span class="initializer"> = &quot;&quot;</span></span>): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getctime.html" class="methodname">SplFileInfo::getCTime</a></span>(): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getextension.html" class="methodname">SplFileInfo::getExtension</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getfileinfo.html" class="methodname">SplFileInfo::getFileInfo</a></span>(<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$class</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><a href="class.splfileinfo.html" class="type SplFileInfo">SplFileInfo</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getfilename.html" class="methodname">SplFileInfo::getFilename</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getgroup.html" class="methodname">SplFileInfo::getGroup</a></span>(): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getinode.html" class="methodname">SplFileInfo::getInode</a></span>(): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getlinktarget.html" class="methodname">SplFileInfo::getLinkTarget</a></span>(): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getmtime.html" class="methodname">SplFileInfo::getMTime</a></span>(): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getowner.html" class="methodname">SplFileInfo::getOwner</a></span>(): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getpath.html" class="methodname">SplFileInfo::getPath</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getpathinfo.html" class="methodname">SplFileInfo::getPathInfo</a></span>(<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$class</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type">?</span><span class="type"><a href="class.splfileinfo.html" class="type SplFileInfo">SplFileInfo</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getpathname.html" class="methodname">SplFileInfo::getPathname</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getperms.html" class="methodname">SplFileInfo::getPerms</a></span>(): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getrealpath.html" class="methodname">SplFileInfo::getRealPath</a></span>(): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.getsize.html" class="methodname">SplFileInfo::getSize</a></span>(): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.gettype.html" class="methodname">SplFileInfo::getType</a></span>(): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.isdir.html" class="methodname">SplFileInfo::isDir</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.isexecutable.html" class="methodname">SplFileInfo::isExecutable</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.isfile.html" class="methodname">SplFileInfo::isFile</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.islink.html" class="methodname">SplFileInfo::isLink</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.isreadable.html" class="methodname">SplFileInfo::isReadable</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.iswritable.html" class="methodname">SplFileInfo::isWritable</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.openfile.html" class="methodname">SplFileInfo::openFile</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$mode</code><span class="initializer"> = &quot;r&quot;</span></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$useIncludePath</code><span class="initializer"> = <strong><code>false</code></strong></span></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type">resource</span><span class="type"></span></span> <code class="parameter">$context</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><a href="class.splfileobject.html" class="type SplFileObject">SplFileObject</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.setfileclass.html" class="methodname">SplFileInfo::setFileClass</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$class</code><span class="initializer"> = SplFileObject::class</span></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.setinfoclass.html" class="methodname">SplFileInfo::setInfoClass</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$class</code><span class="initializer"> = SplFileInfo::class</span></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splfileinfo.tostring.html" class="methodname">SplFileInfo::__toString</a></span>(): <span class="type">string</span></div>

   }</div>
 
  </div>
 


 </div>
 
 




































































































































































 
<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="directoryiterator.construct.html">DirectoryIterator::__construct</a> — Constructs a new directory iterator from a path</li><li><a href="directoryiterator.current.html">DirectoryIterator::current</a> — Return the current DirectoryIterator item</li><li><a href="directoryiterator.getatime.html">DirectoryIterator::getATime</a> — Get last access time of the current DirectoryIterator item</li><li><a href="directoryiterator.getbasename.html">DirectoryIterator::getBasename</a> — Get base name of current DirectoryIterator item</li><li><a href="directoryiterator.getctime.html">DirectoryIterator::getCTime</a> — Get inode change time of the current DirectoryIterator item</li><li><a href="directoryiterator.getextension.html">DirectoryIterator::getExtension</a> — Gets the file extension</li><li><a href="directoryiterator.getfilename.html">DirectoryIterator::getFilename</a> — Return file name of current DirectoryIterator item</li><li><a href="directoryiterator.getgroup.html">DirectoryIterator::getGroup</a> — Get group for the current DirectoryIterator item</li><li><a href="directoryiterator.getinode.html">DirectoryIterator::getInode</a> — Get inode for the current DirectoryIterator item</li><li><a href="directoryiterator.getmtime.html">DirectoryIterator::getMTime</a> — Get last modification time of current DirectoryIterator item</li><li><a href="directoryiterator.getowner.html">DirectoryIterator::getOwner</a> — Get owner of current DirectoryIterator item</li><li><a href="directoryiterator.getpath.html">DirectoryIterator::getPath</a> — Get path of current Iterator item without filename</li><li><a href="directoryiterator.getpathname.html">DirectoryIterator::getPathname</a> — Return path and file name of current DirectoryIterator item</li><li><a href="directoryiterator.getperms.html">DirectoryIterator::getPerms</a> — Get the permissions of current DirectoryIterator item</li><li><a href="directoryiterator.getsize.html">DirectoryIterator::getSize</a> — Get size of current DirectoryIterator item</li><li><a href="directoryiterator.gettype.html">DirectoryIterator::getType</a> — Determine the type of the current DirectoryIterator item</li><li><a href="directoryiterator.isdir.html">DirectoryIterator::isDir</a> — Determine if current DirectoryIterator item is a directory</li><li><a href="directoryiterator.isdot.html">DirectoryIterator::isDot</a> — Determine if current DirectoryIterator item is '.' or '..'</li><li><a href="directoryiterator.isexecutable.html">DirectoryIterator::isExecutable</a> — Determine if current DirectoryIterator item is executable</li><li><a href="directoryiterator.isfile.html">DirectoryIterator::isFile</a> — Determine if current DirectoryIterator item is a regular file</li><li><a href="directoryiterator.islink.html">DirectoryIterator::isLink</a> — Determine if current DirectoryIterator item is a symbolic link</li><li><a href="directoryiterator.isreadable.html">DirectoryIterator::isReadable</a> — Determine if current DirectoryIterator item can be read</li><li><a href="directoryiterator.iswritable.html">DirectoryIterator::isWritable</a> — Determine if current DirectoryIterator item can be written to</li><li><a href="directoryiterator.key.html">DirectoryIterator::key</a> — Return the key for the current DirectoryIterator item</li><li><a href="directoryiterator.next.html">DirectoryIterator::next</a> — Move forward to next DirectoryIterator item</li><li><a href="directoryiterator.rewind.html">DirectoryIterator::rewind</a> — Rewind the DirectoryIterator back to the start</li><li><a href="directoryiterator.seek.html">DirectoryIterator::seek</a> — Seek to a DirectoryIterator item</li><li><a href="directoryiterator.tostring.html">DirectoryIterator::__toString</a> — Get file name as a string</li><li><a href="directoryiterator.valid.html">DirectoryIterator::valid</a> — Check whether current DirectoryIterator position is a valid file</li></ul>
</div>
</div></div></body></html>